import request from "@/utils/request";
// * Pod维度 获取节点或线上平均响应时间和同环比数据
export const avgRespTimeByPod = (params) => {
  return request.post("/topology-analyzer/connection/avgRespTimeByPod", params);
};

export const getAvgRespTime = (params) => {
  return request.post("/topology-analyzer/connection/avgRespTime", params);
};

// srtt
export const querySRTTLine = (params, type) => {
  return request.post(`/k8s-${type}/SRTT/line`, params);
};

// * 拓扑详情折线图
export const queryRequestTotalLine = (params, type) => {
  return request.post(`/k8s-${type}/requestTotal/line`, params);
};

export const queryErrorLine = (params, type) => {
  return request.post(`/k8s-${type}/errorRate/line`, params);
};

export const queryRespTimeLine = (params, type) => {
  return request.post(`/k8s-${type}/respTime/line`, params);
};

export const queryP95RespTimeLine = (params, type) => {
  return request.post(`/k8s-${type}/p95/line`, params);
};
// 丢包数折线图
export const queryPacketLossLine = (params, type) => {
  return request.post(`/k8s-${type}/packetLoss/line`, params);
};
// 重传数
export const queryRetransmitLine = (params, type) => {
  return request.post(`/k8s-${type}/retransmit/line`, params);
};
// 0窗口
export const queryZeroWindowLine = (params, type) => {
  return request.post(`/k8s-${type}/zeroWindow/line`, params);
};
// 活跃会话数
export const querySessionCountLine = (params, type) => {
  return request.post(`/k8s-${type}/activeConnect/line`, params);
};
// 发包数
export const querySendPackageLine = (params, type) => {
  return request.post(`/k8s-${type}/sendPackage/line`, params);
};
// 收包数
export const queryReceiverPackageLine = (params, type) => {
  return request.post(`/k8s-${type}/receiverPackage/line`, params);
};

// * 资源tab
// 系统资源概览
export const getSystemResourceDetail = (params) => {
  return request.get("/system-resource/details", { params });
};
// 拓扑分析资源概览
export const getTopologyResourceDetail = (params) => {
  return request.get("/topology-analyzer/resource/details", {
    params,
  });
};
export const getHierarchyTopoData = (params) => {
  return request.get("/hierarchical-topology", { params });
};

export const getPodEvent = (params) => {
  return request.get("/k8s-pod/getPodEvent", { params });
};

// 命名空间-CPU使用量折线图
export const namespaceCPUUsage = (params) => {
  return request.get("/k8s-namespace/getNamespaceCpuUsageRange", { params });
};

// 容器详情-cpu使用量
export const containerCpu = (params) => {
  return request.get("/k8s-container/getContainerDetailCpuUsageRange", {
    params,
    headers: {
      Authorization: params.masterIp,
    },
  });
};

// 节点详情-CPU使用量
export const getNodeDetailCPUUsage = (params) => {
  return request.get("/k8s-node/getNodeDetailCPUUsageRange", {
    params,
  });
};
// pod详情-cpu使用量
export const getPodCpuRange = (params) => {
  return request.get("/k8s-pod/getPodCpuRange", { params });
};

// 工作负载详情-CPU使用量
export const getWorkloadCpuUsage = (params) => {
  return request.get("/k8s-workload/cpuUsageRange", { params });
};

// 拓扑分析资源cpu使用趋势图
export const getTopologyCpuUsage = (params) => {
  return request.get("/topology-analyzer/cpuUsageRange", {
    params,
  });
};

// 命名空间-内存使用率折线图
export const namespaceMemoryUsage = (params) => {
  return request.get("/k8s-namespace/getNamespaceMemoryUsageRange", { params });
};

// 容器详情-内存使用量
export const containerMemory = (params) => {
  return request.get("/k8s-container/getContainerDetailMemoryUsageRange", {
    params,
    headers: {
      Authorization: params.masterIp,
    },
  });
};

// 节点详情-内存使用量
export const getNodeDetailMemoryUsage = (params) => {
  return request.get("/k8s-node/getNodeDetailMemoryUsageRange", {
    params,
  });
};

// pod详情-内存使用量
export const getPodMemoryRange = (params) => {
  return request.get("/k8s-pod/getPodMemoryRange", { params });
};

// 工作负载详情-内存使用量折线图
export const getWorkloadMemoryUsage = (params) => {
  return request.get("/k8s-workload/memoryUsageRange", { params });
};

// 拓扑分析资源内存使用趋势图
export const getTopologyMemoryUsage = (params) => {
  return request.get("/topology-analyzer/memoryUsageRange", {
    params,
  });
};

// 命名空间-磁盘使用率折线图
export const namespaceDiskUsage = (params) => {
  return request.get("/k8s-namespace/getNamespaceFsUsageRange", { params });
};

// 容器详情-磁盘使用量
export const containerDisk = (params) => {
  return request.get("/k8s-container/getContainerDetailDiskUsageRange", {
    params,
    headers: {
      Authorization: params.masterIp,
    },
  });
};

// 节点详情-磁盘使用量区间
export const getNodeDetailDiskUsageRange = (params) => {
  return request.get("/k8s-node/getNodeDetailDiskUsageRange", {
    params,
  });
};

// pod详情-磁盘使用量
export const getPodFsRange = (params) => {
  return request.get("/k8s-pod/getPodFsRange", { params });
};

// 工作负载详情-磁盘使用量折线图
export const getWorkloadDiskUsage = (params) => {
  return request.get("/k8s-workload/fsUsageRange", { params });
};

// 拓扑分析资源磁盘使用趋势图
export const getTopologyDiskUsage = (params) => {
  return request.get("/topology-analyzer/fsUsageRange", {
    params,
  });
};

export const getHierachyTopoNamespaceDetail = (params) => {
  return request.get("/hierarchical-topology/details/namespace", {
    params,
  });
};
export const getHierachyTopoContainerDetail = (params) => {
  return request.get("/hierarchical-topology/details/container", {
    params,
  });
};

export const getHierachyTopoNodeDetail = (params) => {
  return request.get("/hierarchical-topology/details/node", {
    params,
  });
};

export const getHierachyTopoPodDetail = (params) => {
  return request.get("/hierarchical-topology/details/pod", {
    params,
  });
};
// 容器列表
export const getContainerList = (params) => {
  return request.get("/k8s-container/getContainerList", {
    params,
    headers: {
      Authorization: params.masterIp,
    },
  });
};
export const getHierachyTopoServiceDetail = (params) => {
  return request.get("/hierarchical-topology/details/service", {
    params,
  });
};
export const getHierachyTopoWorkloadDetail = (params) => {
  return request
      .get("/hierarchical-topology/details/workload", { params })

};
// 获取对应namespace、等的yaml信息
export const getK8sYaml = (params) => {
  return request.get('/k8s/api/server/yaml', { params });
}

// 系统资源cpu使用趋势图
export const getSystemCpuUsage = (params) => {
  return request.get('/system-resource/cpuUsageRange', { params });
}
// 系统资源内存使用趋势图
export const getSystemMemoryUsage = (params) => {
  return request.get('/system-resource/memoryUsageRange', { params });
}
// 系统资源磁盘使用趋势图
export const getSystemDiskUsage = (params) => {
  return request.get('/system-resource/fsUsageRange', { params });
}


// pod重启次数
export const getPodRestartLine = (params) => {
  return request.get("/k8s-pod/restart/line", { params });
};


//容器详情-tcp全连接半连接队列区间
export const getContainerTcpBackLogRange = (params) => {
  return request.get("/k8s-container/getContainerTcpBacklogRange", {
    params,
    headers: {
      Authorization: params.masterIp,
    },
  });
};

// 获取当前节点的全量调用关系
export const getEdgeFullData = (data, params) => {
  return request.post("/topology-analyzer/full/data", data, {
      params,
  });
};
export const getExceptionList = (params) => {
  return request.post('/exception/list', params);
}

export const systemExcepCall = (params) => {
  return request.get('/system-node/exp_syscall', { params })
}
export const systemTopoGraph = (params) => {
  return request.get("/system-resource/getTopologyGraph", { params });
}
// pod详情-获取pod拓扑图
export const getPodTopologyGraph = (params) => {
  return request.get("/k8s-pod/getTopologyGraph", { params });
};
export const flameGraphList = (params) => {
  return request.post("/flame-graph/process", params)
}
// 下拉选项-pod
export const getPodOptions = (params) => {
  return request.get('/cluster/option/pod', { params })
}
// 下拉选项-容器
export const getContainerOptions = (params) => {
  return request.get('/cluster/option/container', { params })
}


